cmake_minimum_required(VERSION 3.8)
project(robot_one_navigation)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(nav2_msgs REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(pluginlib REQUIRED)
find_package(nav2_core REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

add_executable(robot_pose_init src/robot_pose_init.cpp)
add_executable(nav_to_point src/nav_to_point.cpp)
add_executable(nav_to_multiple_point src/nav_to_multiple_point.cpp)

ament_target_dependencies(
  robot_pose_init
  "rclcpp"
  "std_msgs"
  "geometry_msgs"
  "nav2_msgs"
)
ament_target_dependencies(
  nav_to_point
  "rclcpp"
  "std_msgs"
  "geometry_msgs"
  "nav2_msgs"
  rclcpp_action
)
ament_target_dependencies(
  nav_to_multiple_point
  "rclcpp"
  "std_msgs"
  "geometry_msgs"
  "nav2_msgs"
  rclcpp_action
)
install(TARGETS robot_pose_init
  DESTINATION lib/${PROJECT_NAME}
)
install(TARGETS nav_to_point
  DESTINATION lib/${PROJECT_NAME}
)
install(TARGETS nav_to_multiple_point
  DESTINATION lib/${PROJECT_NAME}
)


if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # comment the line when a copyright and license is added to all source files
  set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # comment the line when this package is in a git repo and when
  # a copyright and license is added to all source files
  set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

install(DIRECTORY launch config maps src behavior_trees
  DESTINATION share/${PROJECT_NAME}
)

# 创建规划插件库
add_library(nav_planner_test_plugin SHARED src/plugin/nav_planner_test.cpp)
# 添加依赖和头文件路径
ament_target_dependencies(nav_planner_test_plugin nav2_core pluginlib)
target_include_directories(nav_planner_test_plugin PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>
)


# 创建控制插件库
add_library(nav_controller_test_plugin SHARED src/plugin/nav_controller_test.cpp)
# 添加依赖和头文件路径
ament_target_dependencies(nav_controller_test_plugin nav2_core pluginlib)
target_include_directories(nav_controller_test_plugin PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>
)


# 创建Astar插件库
add_library(Astar_planner_plugin SHARED 
  src/plugin/A_Star/Astar_planner.cpp
  src/plugin/A_Star/Astar.cpp)
# 添加依赖和头文件路径
ament_target_dependencies(Astar_planner_plugin nav2_core pluginlib)
target_include_directories(Astar_planner_plugin PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>
)

# 安装库和头文件
install(TARGETS 
  nav_controller_test_plugin
  nav_planner_test_plugin
  Astar_planner_plugin
  LIBRARY DESTINATION lib
)
install(DIRECTORY include/ DESTINATION include/)


pluginlib_export_plugin_description_file(nav2_core nav_planner_test_plugin.xml)
pluginlib_export_plugin_description_file(nav2_core nav_controller_test_plugin.xml)
pluginlib_export_plugin_description_file(nav2_core Astar_planner_plugin.xml)

ament_package()
